//标签切换
function tabs(thisli,divname)
{
	$("#"+divname).show().siblings(".tabdiv").hide();
	$(thisli).addClass("tabon").siblings("li").removeClass("tabon");
}

//选中checkbox
function gchecked_sear(ovalue,val,divid)
{
	$("#sear_now").html(ovalue);
	invalue(val,divid);
}

//选中checkbox
function gchecked(o,val,divid)
{
	$(o).addClass("gcheckbox_on").siblings().removeClass("gcheckbox_on");
	invalue(val,divid);
}

//赋值函数
function invalue(val,divid)
{
	$(divid).val(val);
}

//注册协议
function reg_xieyi(ifbtn)
{
	protocol = ""
	
	$.ajax({
	type:"post",
	url:"/Mobile/index/protocol.html",
	data:{"name":"test","id":"11"},
	dataType:"json",
	
	success:function(data)
	{
		html = '<div class="reg_xieyi_box">';
		html += '<div class="reg_xieyi_tit">朋伴网络服务使用协议</div>';
		html += '<div class="reg_xieyi_con"><div class="wrapper">';
		
		protocol = data.msg;
		protocol = HTMLDecode(protocol);
		html += protocol;
		
		<!----------------------------->
		html += '</div></div>';
		html += '<div class="reg_xieyi_btn"><button class="reg_btn reg_bqx" type="button" onclick="reg_close('+ifbtn+')">取消</button><button class="reg_btn reg_bjs" type="button" onclick="reg_ok('+ifbtn+')">同意</button></div>';
		html += '</div>';
		layer.open({
			type: 1,
			title: false,
			area: ['96%', '70%'], //宽高
			shadeClose: true, //开启遮罩关闭
			content: html
		});
	}
	});
}

function HTMLDecode(text) { 
var temp = document.createElement("div"); 
temp.innerHTML = text; 
var output = temp.innerText || temp.textContent; 
temp = null; 
return output; 
}

function reg_close(ifbtn)
{
	if(ifbtn)
	{
		document.getElementById("ifaggree").checked=false;
	}
	layer.closeAll();
}

function reg_ok(ifbtn)
{
	if(ifbtn)
	{
		document.getElementById("ifaggree").checked=true;
	}
	layer.closeAll();
}

function tip_confirm(tip,url)
{
	layer.confirm(tip,{
		icon: 2,
		btn: ['确定','取消'] //按钮
	},function(){
		window.location.href=url;
	});
}

/**
 * 邮箱格式判断
 * @param str
 */
function checkEmail(str){
    var reg = /^[a-z0-9]([a-z0-9\\.]*[-_]{0,4}?[a-z0-9-_\\.]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+([\.][\w_-]+){1,5}$/i;
    if(reg.test(str)){
        return true;
    }else{
        return false;
    }
}

/**
 * 手机号码格式判断
 * @param tel
 * @returns {boolean}
 */
function checkMobile(tel) {
    var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
    if (reg.test(tel)) {
        return true;
    }else{
        return false;
    };
}

//底部客服
$(function(){
	$(".ikefu_close").click(function(){
		$(".index_kefuico").show();
		$(".index_kefu").hide();
        $.ajax({
            type : "get",
            dataType:'json',
            url:"/index.php?m=Mobile&c=Index&a=set_kf_cookie&kf_hide=1",

        });
	});
	$(".index_kefuico").click(function(){
		$(".index_kefuico").hide();
		$(".index_kefu").show();
        $.ajax({
            type : "get",
            dataType:'json',
            url:"/index.php?m=Mobile&c=Index&a=set_kf_cookie&kf_hide=0",

        });
	});
});